package com.chagee.store.operation.api.enums;

import com.google.common.collect.Sets;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

/**
 * 结算单状态
 * @Author : hk
 * @Date : 2024/10/21
 */

@Getter
@AllArgsConstructor
public enum SettlementStatusEnum {

	//待项目组下发
	WAIT_ISSUED("WAIT_ISSUED", "待项目组下发"),

	//门店有异议
	STORE_OBJECTION("STORE_OBJECTION", "门店有异议"),

	//供应商有异议
	SUPPLIER_OBJECTION("SUPPLIER_OBJECTION", "供应商有异议"),

	//待门店确认
	WAIT_STORE_VERIFY("WAIT_STORE_VERIFY", "待门店确认"),

	//待供应商确认
	WAIT_SUPPLIER_VERIFY("WAIT_SUPPLIER_VERIFY", "待供应商确认"),

	//待供应商提交发票
	SUBMIT_INVOICE("SUBMIT_INVOICE", "待供应商提交发票"),

	//待支付
	WAIT_PAY("WAIT_PAY", "待支付"),

	//已支付
	ALREADY_PAY("ALREADY_PAY", "已支付"),

	//已完成
	COMPLETE("COMPLETE", "已完成"),

	;

	private final String type;
	private final String desc;


	public static SettlementStatusEnum queryByType(String type) {
		for (SettlementStatusEnum value : values()) {
			if (Objects.equals(type, value.getType())) {
				return value;
			}
		}
		return null;
	}

	public static SettlementStatusEnum of(String type) {
		return Stream.of(SettlementStatusEnum.values()).filter(v -> v.type.equalsIgnoreCase(type)).findFirst().orElse(null);
	}

	public static final Set<String> SETTLEMENT_ADJUST_TYPE = Sets.newHashSet(
		SettlementStatusEnum.WAIT_ISSUED.getType(),
		SettlementStatusEnum.STORE_OBJECTION.getType(),
		SettlementStatusEnum.SUPPLIER_OBJECTION.getType());

	public static final Set<String> SETTLEMENT_ISSUED_TYPE = Sets.newHashSet(
		SettlementStatusEnum.WAIT_ISSUED.getType(),
		SettlementStatusEnum.STORE_OBJECTION.getType(),
		SettlementStatusEnum.SUPPLIER_OBJECTION.getType());
}
